{template header}
<style type="text/css">
    .bg{display:none;position:fixed;width:100%;height:100%;background:#000;z-index:2;top:0;left:0;opacity:0.7;}
</style>
<h4 style="padding-left:10px;;">
    <span>物流模板管理</span>
</h4>
<form class="form-horizontal" method="POST" action="?c=adminErp&a=getLogisticsTep"  >
    <div class="control-group search-group" style="margin:0;">
        <label class="control-label" >模板名：</label>
        <div class="controls">
           <input type="text" value="{$name}" name="name" placeholder="模板名" />
            <input class="btn" type="submit" value="查询" />
            <button class="btn btn-primary" type="button" id="addCt">+</button>
        </div>
    </div>
</form>

<div class="bs-docs-example table-align pt-15" style="clear:both;">
    <table class="table table-striped table-align">
        <thead>
        <tr>
            <th>模板ID</th>
            <th>模板名称</th>
            <th>操作</th>
        </tr>
        </thead>
        {if count($info)>0}
        <tbody>
        {loop $info $k $v}
            <tr>
                <td>{$v['id']}</td>
                <td>{$v['title']}</td>
                <td><a href="javascript:void(0);" id="addLog_{$v['id']}" ids="{$v['id']}" ids_title="{$v['title']}">编辑</a></td>
            </tr>

        {/loop}
        <div id="res"></div>
        </tbody>
        {/if}
    </table>

</div>
<div class="pagination">
    <ul>
        {$pageStr}
    </ul>
</div>
{template footer}
<div class="bg" id="bgx"></div>
<div id="dialog" style="position: absolute; z-index: 1003;background-color:white; display: none;" >
    <div  style="margin:50px 100px;">
        <div class="controls">
            模板名：<input type="text" value="" id="remark" placeholder="模板名" /><br />
            <div style="text-align: center">
               <button class="btn btn-primary" id="ok" ids="">确定</button>
               <button class="btn btn-primary" id="close" >取消</button>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
    //$("#bgx").show();
    //letDivCenter('#loading');
    $('#addCt').on('click',function(){
        $("#bgx").show();
        $('#ok').attr({ids:''});
        $('#remark').val('');
        letDivCenter('#dialog');
    })

    $("a[id^='addLog_']").on('click',function () {
        var _this = $(this), ids_title = _this.attr('ids_title');
        $("#bgx").show();
        letDivCenter('#dialog');
        $('#ok').attr({ids:_this.attr('ids')});
        $('#remark').val(ids_title);
    })
    $('#ok').on('click',function(){
        var _this = $(this),ids=_this.attr('ids');
        $.ajax({
            type:'POST',
            url:'?c=adminErp&a=addLogisticsTep',
            data:{id:ids,remark:$('#remark').val()},
            dataType:'json',
            success:function(d){
                if(d.status=='ok'){
                    alert(d.error_msg);
                    window.location.reload();
                }else{
                    alert(d.error_msg);
                }
            }
        })
    })
    $('#close').on('click',function(){
        $('#dialog').css('display','none');
        $("#bgx").fadeOut(300);
    })
    function letDivCenter(divName){
        var divObj = $(divName);
        var wWidth = $(document.body).width(),wHeight = $(window).height();
        var divWidth = divObj.width(),divHeight = divObj.height();
        divObj.css({'left':(wWidth-divWidth)/2+$(window).scrollLeft(),'top':(wHeight-divHeight)/2+$(window).scrollTop(),'display':'block'});
        $(window).bind('scroll resize',function(){
            $(divName).css({'left':(wWidth-divWidth)/2+$(window).scrollLeft(),'top':(wHeight-divHeight)/2+$(window).scrollTop()});
        });
    }

</script>